<%inherit file="base.html"/>

<%def name="head()">
<style type="text/css">
    td {
        text-align: left
    }
</style>
<script>
    function deleteProduct(product_id) {
        if (confirm("确认删除吗？")) {
            window.location.href = "/admin/product/delete?product_id=" + product_id;
        }
    }
</script>
</%def>

<%def name="body()">
<section class="content">
    <div class="box box-default">
        <div class="box-header">
            <i class="fa fa-archive"></i>
            <h3 class="box-title">资费列表</h3>
        </div>
    <div class="box-body">
     <div class="container">
        <div class="pull-left bottom10">
            % if permit.match(current_user.username,'/admin/product/add'):
            <a href="/admin/product/add" class="btn btn-sm bg-navy">添加资费</a>
            % endif
        </div>

        <table class="table table-hover">
            <thead>
            <tr>
                <th>资费名称</th>
                <th>资费策略</th>
                <th>价格(元)</th>
                <th>并发数</th>
                <th>是否绑定MAC</th>
                <th>是否绑定VLAN</th>
                <th>上行速率</th>
                <th>下行速率</th>
                <th>状态</th>                
            </tr>
            </thead>
            <tbody>
            % for product in page_data.result:
            <tr>
                <td><a href="/admin/product/detail?product_id=${product.id}">${product.product_name}</a></td>
                <td>
                    ${product_policys[product.product_policy]}
                </td>
                <td>${utils.fen2yuan(product.fee_price)}</td>
                <td>${product.concur_number}</td>
                <td>${product.bind_mac and u'是' or u'否'}</td>
                <td>${product.bind_vlan and u'是' or u'否'}</td>
                <td>${utils.bps2mbps(product.input_max_limit)} Mbps</td>
                <td>${utils.bps2mbps(product.output_max_limit)} Mbps</td>
                <td>${product.product_status and u'停用' or u'正常'}</td>
                <td>
                    % if not product.product_policy == 6:
                    % if permit.match(current_user.username, '/admin/product/update'):
                    <a class="opt-btn btn-default" href="/admin/product/update?product_id=${product.id}">修改</a>
                    % endif
                    % if permit.match(current_user.username, '/admin/product/delete'):
                    <a class="opt-btn btn-default"  href="javascript:deleteProduct('${product.id}')">删除</a>
                    % endif
                    % endif
                </td>
            </tr>
            % endfor
            </tbody>
        </table>
        ${page_data.render()}
    </div>
</div>
</div>
</section>
</%def>